package model;

/**
 * Taxes is a field where the user has to pay an amount when he lands on it.
 * @author Group 20
 */
public class Taxes extends Field
{
	private int tax;
	
	/**
	 * Constructor
	 * @param number: Field number
	 * @param name: Field name
	 * @param description: Field description
	 * @param tax: Field tax value
	 */
	public Taxes(int number, String name, String description, int tax) 
	{
		super(number, name, description);
		this.tax = tax;
	}


	/**
	 * Returns if the user has enough money to pay, and withdraws the money if he has.
	 */
	@Override
	public boolean landOnField(Player player, int dicesSum, int numOfFieldTypeOwned) 
	{
		if (player.getBalance() >= tax){
			player.withdraw(tax);
			return true;
		}
		return false;
		
	}

	/**
	 * toString Method
	 */
	@Override
	public String toString() {
		return super.toString() + "Taxes [tax=" + tax + "].";
	}


	/**
	 * Gets the payment that determines if the user has to pay or get money.
	 */
	@Override
	public int getPayment() 
	{
		return -tax;
	}	
}
